//
//  RBOneKeyLogin.m
//  RMMaterialRed
//
//  Created by XBWH on 2024/3/6.
//

#import "RBOneKeyLogin.h"

@interface RBOneKeyLogin ()

@property (nonatomic,assign) RBOneKeyLoginVcType typeVc;
@property (nonatomic,assign) NSInteger selectIndex;
@property (nonatomic,copy) NSString *otherSource;
 
@end

@implementation RBOneKeyLogin

RBOneKeyLogin *_shareInstance = nil;
+ (instancetype)shareInstance {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _shareInstance = [[RBOneKeyLogin alloc]init];
    });
    return _shareInstance;
}
- (void)rb_startLoginWithControllerType:(RBOneKeyLoginVcType)typeVc tabBarItemSelectIndex:(NSInteger)selectIndex otherSource:(NSString * __nullable)otherSource{
    self.typeVc = typeVc;
    self.selectIndex = selectIndex;
    self.otherSource = otherSource;
    
    [self rb_startNormalLoginVc];
}
-(void)rb_startNormalLoginVc{
    RBLoginController *loginVc = [[RBLoginController alloc] init];
    RBNavigationController *navVc = [[RBNavigationController alloc] initWithRootViewController:loginVc];
    loginVc.isRootController = _isRootController;
    loginVc.selectedIndex = _selectIndex;
    loginVc.source = _otherSource;
    if (self.typeVc==RBOneKeyLoginVcTypeTabBar) {
        loginVc.hidesBottomBarWhenPushed = YES;
    }
    if (_isRootController) {
        [[RBTool rb_getCurrentController].navigationController pushViewController:loginVc animated:YES];
    }else{
        navVc.modalPresentationStyle = UIModalPresentationFullScreen;
        [[RBTool rb_getCurrentController] presentViewController:navVc animated:YES completion:nil];
    }
}
@end
